package com.hcb.micro.sdk;
import javax.swing.*;

public class BankcardAuth {
	static String ji[];
	static String ou[];
	static int sum;
	static int k, j;
	static StringBuffer jwi = new StringBuffer();
	static StringBuffer owu = new StringBuffer();
	static String n = JOptionPane.showInputDialog(null, "请输入卡号，进行系统验证合法与否");

	public static void main(String args[]) {
		JOptionPane.showConfirmDialog(null, "您输入的卡号是:" + n);
		String[] s = n.split("");
		/*
		 * 验证数组的正确性 for(int i=0;i<s.length;i++) { System.out.println(s[i]+" ");
		 * }
		 */
		for (int i = s.length - 1; i >= 0; i -= 2) {
			jwi.append(s[i]);
		}
		for (int i = s.length - 2; i >= 0; i -= 2) {
			owu.append(s[i]);
		}
		ji = jwi.toString().split("");
		ou = owu.toString().split("");

		// *验证奇数偶数数组
		for (int i = 0; i < ji.length; i++)
			System.out.println(ji[i]);
		for (int i = 0; i < ou.length; i++)
			System.out.println(ou[i]);
		// 开始检验真伪
		for (int i = 1; i < ji.length; i++) {
			System.out.println("success。。。。" + ji[i]);
			// int f=(new Integer(ji[i]).intValue());
			// sum+=f;
		}
		for (int i = 1; i < ou.length; i++) {
			int f = (new Integer(ou[i]).intValue());
			if (f > 10)
				f -= 9;
			sum += f;
		}
		if (sum % 10 == 0)
			JOptionPane.showMessageDialog(null, "你的卡号是真的");
		else
			JOptionPane.showMessageDialog(null, "你的卡号是假的");
	}
}